package org.edu.modules.sxjy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.edu.modules.sxjy.entity.VeCommon;
import org.edu.modules.sxjy.entity.VeCompanyUser;
import org.edu.modules.sxjy.entity.VeDgsxResidentTeacher;
import org.edu.modules.sxjy.mapper.VeCompanyMapper;
import org.edu.modules.sxjy.mapper.VeDgsxResidentTeacherMapper;
import org.edu.modules.sxjy.service.IVeDgsxResidentTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class VeDgsxResidentTeacherServiceImpl
        extends ServiceImpl<VeDgsxResidentTeacherMapper, VeDgsxResidentTeacher>
        implements IVeDgsxResidentTeacherService
{
    @Autowired
    private VeDgsxResidentTeacherMapper veDgsxResidentTeacherMapper;
    @Autowired
    private VeCompanyMapper veCompanyMapper;

    public List<Map<String, Object>> selectPageList(VeDgsxResidentTeacher veDgsxResidentTeacher, Integer startLine, Integer pageSize, VeCommon veCommon)
    {
        List<Map<String, Object>> list = new ArrayList();
        if (veCommon.getUserType().contains("3"))
        {
            VeCompanyUser veCompanyUser = this.veCompanyMapper.getCpUserByUserId(veCommon.getUserId());
            if ((veCompanyUser != null) && (!"".equals(veCompanyUser))) {
                list = this.veDgsxResidentTeacherMapper.selectPageList(veDgsxResidentTeacher, startLine, pageSize, Integer.valueOf(veCompanyUser.getCpId()));
            }
        }
        else
        {
            list = this.veDgsxResidentTeacherMapper.selectPageList(veDgsxResidentTeacher, startLine, pageSize, null);
        }
        return list;
    }

    public int getSumPage(VeDgsxResidentTeacher veDgsxResidentTeacher, VeCommon veCommon)
    {
        int num = 0;
        if (veCommon.getUserType().contains("3"))
        {
            VeCompanyUser veCompanyUser = this.veCompanyMapper.getCpUserByUserId(veCommon.getUserId());
            if ((veCompanyUser != null) && (!"".equals(veCompanyUser))) {
                num = this.veDgsxResidentTeacherMapper.getSumPage(veDgsxResidentTeacher, Integer.valueOf(veCompanyUser.getCpId()));
            }
        }
        else
        {
            num = this.veDgsxResidentTeacherMapper.getSumPage(veDgsxResidentTeacher, null);
        }
        return num;
    }

    public int deleteByCpId(String cpId)
    {
        return this.veDgsxResidentTeacherMapper.deleteByCpId(cpId);
    }

    public int deleteByCpIds(String[] cpIds)
    {
        return this.veDgsxResidentTeacherMapper.deleteByCpIds(cpIds);
    }
}
